<?xml version="1.0" ?>
<tasks>
  <% PNEngine::Transition.find(:all, :order => "id ASC").select{ |transition| transition.active? }.each do |transition| %>
    <% if params[:id].to_i == 0 && transition.incoming_places.size == 0%>
      <task>
        <transition_id><%= transition.id %></transition_id>
        <transition_name><%= transition.name %></transition_name>
        <case_id>0</case_id>
        <pending_time>0</pending_time>
        <actual_owner><%= transition.getOwner unless transition.getOwner.nil? %></actual_owner>
        <role><%= transition.role unless transition.role.nil?  %></role>
        <net_name><%= transition.petrinet.name %></net_name>
        <role_enabled><%= transition.eval_role %></role_enabled>
        <user_enabled><%= transition.eval_owner %></user_enabled>
        <delegation_ratio>0</delegation_ratio>
      </task>
    <%  else %>  
      <% transition.active_combinations.each do |combination| %>
        <% if combination.select { |token| combination.first.case.id == params[:id].to_i }.size > 0%>
          <task>
            <transition_id><%= transition.id %><%= "/tokens/"+combination.collect{|token| token.id}.join("/") unless combination.empty? %></transition_id>
            <transition_name><%= transition.name %></transition_name>
            <action><%= transition.action %></action>
            <case_id><%= combination.first.nil? ? 0 : combination.first.case.id %></case_id>
            <attractivity><%= sprintf("%.2f", PNEngine::CsvLogger.get_task_attractivity(transition.name) * 100) %></attractivity>
            <pending_time><%= sprintf("%.2f", PNEngine::CsvLogger.get_task_timeperiod(transition.name, 'allocate', combination.first.case.id)) unless combination.first.nil? %></pending_time>
            <actual_owner><%= transition.getOwner unless transition.getOwner.nil? %></actual_owner>
            <role><%= transition.role unless transition.role.nil?  %></role>
            <net_name><%= transition.petrinet.name %></net_name>
            <role_enabled><%= transition.eval_role %></role_enabled>
            <user_enabled><%= transition.eval_owner %></user_enabled>
            <delegation_ratio><%= PNEngine::CsvLogger.get_delegation_ratio(transition.name) %></delegation_ratio>
          </task>
        <% end%>
      <% end %>
    <%  end %>
  <% end %>
</tasks>